package com.hbnu.test.www.net;

import Training.Socket_test.Socket_client01;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class TCP_client02 {
    public static void main(String[] args) {
        try (Socket socket = new Socket("127.0.0.1", 6666)) {
            byte[] bytes = "我是张扬啊".getBytes();
            OutputStream outputStream = socket.getOutputStream();
            InputStream inputStream = socket.getInputStream();
            outputStream.write(bytes);
            byte[] receivedata = new byte[1024];
            int len = inputStream.read(receivedata);
            System.out.println("返回信息" + new String(receivedata, 0, len));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
